import axios from 'axios'
import Vue from 'vue'
import Vuex, { Store } from 'vuex'
Vue.use(Vuex)
export default new Vuex.Store({
  state: {
    singerli:[],
    // comment:[],
    song:[],
    new:[],
    very:[],
    mv:[]
     
    
  },
  mutations: {
    singerlis(state,payload){
      state.singerli=payload
    },
    // commentlists(state,payload){
    //   state.comment=payload
    // },
   
    song(state,payload){
      state.song=payload
    },
    new(state,payload){
      state.new=payload
    },
    very(state,payload){
      state.very=payload
    },
    mv(state,payload){
      state.mv=payload
    },
   
    
  },
  actions: {
   singerlist(context,payload){
     var id=localStorage.getItem('id')
     var page=localStorage.getItem('page')
     axios.get(`https://c.y.qq.com/v8/fcg-bin/fcg_v8_toplist_cp.fcg?g_tk=5381&uin=0&format=json&inCharset=utf-8&outCharset=utf-8&notice=1&platform=h5&needNewCode=1&tpl=4&page=2&type=top&topid=${id}&_=1512563984096`)
     .then(res=>{
       console.log(res);
        context.commit('singerlis',res.data)
     }).catch(err=>{
       console.log(err);
     })
   },

   songsheet(context,payload){
     axios.get('http://m.kuwo.cn/newh5app/api/mobile/v1/typelist/playlist')
     .then(res=>{
      console.log(res);
      context.commit('song',res.data.data)
     }).catch(err=>{
       console.log(err);
     })
   },
   newlist(context,payload){
    axios.get('http://m.kuwo.cn/newh5app/api/mobile/v1/playlist/rcm/new').then(res=>{
      // console.log(res.data)
      context.commit('new',res.data.data.prettyList)
    }).catch(err=>{
      console.log(err);
    })
   },
   
   verylist(context,payload){
     axios.get('http://m.kuwo.cn/newh5app/api/mobile/v1/playlist/rcm/hot').then(res=>{
      //  console.log(res);
       context.commit('very',res.data.data.prettyList)
     }).catch(err=>{
       console.log(err);
     })
   },
   mvlist(context,payload){
     axios.get('https://u.y.qq.com/cgi-bin/musics.fcg?-=mvlib8968879789686011&g_tk=5381&sign=zzaxltdllc5jz7cvvcc7620d52be3920c5d6a819c1a511659&loginUin=0&hostUin=0&format=json&inCharset=utf8&outCharset=utf-8&notice=0&platform=yqq.json&needNewCode=0&data=%7B%22comm%22%3A%7B%22ct%22%3A24%7D%2C%22mv_tag%22%3A%7B%22module%22%3A%22MvService.MvInfoProServer%22%2C%22method%22%3A%22GetAllocTag%22%2C%22param%22%3A%7B%7D%7D%2C%22mv_list%22%3A%7B%22module%22%3A%22MvService.MvInfoProServer%22%2C%22method%22%3A%22GetAllocMvInfo%22%2C%22param%22%3A%7B%22start%22%3A0%2C%22size%22%3A20%2C%22version_id%22%3A7%2C%22area_id%22%3A15%2C%22order%22%3A1%7D%7D%7D')
     .then(res=>{
       console.log(res.data);
       context.commit('mv',res.data)
     }).catch(err=>{
       console.log(err);
     })
   }

  },
  

  modules: {
  }
})
